/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2018.10.30     SummerGift   change to new framework
 */

#ifndef __DRV_USART_H__
#define __DRV_USART_H__

#include <rtthread.h>
#include "rtdevice.h"
#include <rthw.h>
#include <drv_common.h>

#ifdef RT_SERIAL_USING_DMA
#include "drv_dma.h"
#endif


int rt_hw_usart_init(void);

/* uart config class */
struct uart_config
{
    const char *name;

    USART_Type *periph; //USART Peripheral base address
    IRQn_Type irq_type; //usart irq number
    
#ifdef RT_SERIAL_USING_DMA    
    struct dma_config *dma_rx;
#endif
};


/* uart dirver class */
struct uart_driver
{
    USART_InitType init; //uart hardware init
    struct uart_config *config; //uart config
    
#ifdef RT_SERIAL_USING_DMA
    struct
    {
        DMA_InitType init;
        
        rt_size_t last_index;
    } dma;
#endif
    rt_uint8_t uart_dma_flag;
    struct rt_serial_device serial;   //uart device
};

#endif  /* __DRV_USART_H__ */
